package javabase.schoolwork.day6_11;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fance
 * @date 2018/6/12 8:41
 */
public class Bank {
    private static Bank bank = new Bank();
    private Bank(){}
    public static Bank getBank() {
        return bank;
    }
    private static List<Account> accounts = new ArrayList<Account>();
    private String name;
    private double oneYearRate;
    private double twoYearsRate;
    private double fiveYearsRate;


    public boolean addAccounts(Account account) {
        if(account==null) {
            return false;
        }
        accounts.add(account);
        return true;
    }
    public Account queryAccount(String accountName) {
        for (Account account : accounts) {
            if (account.getName().equals(accountName)) {
                return account;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "Bank{" +
                "name='" + name + '\'' +
                ", oneYearRate=" + oneYearRate +
                ", twoYearsRate=" + twoYearsRate +
                ", fiveYearsRate=" + fiveYearsRate +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getOneYearRate() {
        return oneYearRate;
    }

    public void setOneYearRate(double oneYearRate) {
        this.oneYearRate = oneYearRate;
    }

    public double getTwoYearsRate() {
        return twoYearsRate;
    }

    public void setTwoYearsRate(double twoYearsRate) {
        this.twoYearsRate = twoYearsRate;
    }

    public double getFiveYearsRate() {
        return fiveYearsRate;
    }

    public void setFiveYearsRate(double fiveYearsRate) {
        this.fiveYearsRate = fiveYearsRate;
    }
}
